﻿namespace il2lua.TypeSystem;

public class ILNameSpace : ILName, INameSpace
{
    public ILNameSpace(string? name, INameSpace? parent) : base(name)
    {
        parent?.Childs.Add(this);
        Parent = parent;
        Childs = new List<INameSpace>();
    }
    public INameSpace? Parent { get; }
    public IList<INameSpace> Childs { get; }
    public override string? FullName
    {
        get
        {
            if (Parent != null && !IsNullOrEmpty(Parent.FullName))
                return $"{Parent.FullName}.{Name}";
            else
                return Name;
        }
    }
    public override string ToString()
    {
        return FullName ?? "<root>";
    }
}
